package com.xinzhi.service.impl;

import cn.hutool.core.util.StrUtil;
import com.xinzhi.mapper.MangerMapper;
import com.xinzhi.pojo.dto.Bumentai;
import com.xinzhi.service.ManagerService;
import com.xinzhi.utils.RedisUtils;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ManagerServiceImpl implements ManagerService {

    @Autowired
    private MangerMapper managerMapper;
    @Autowired
    private RedisUtils redisUtils;

    /**
     * 部门台账评分汇总根据考评对象查询的接口
     * @param object
     * @return
     */
    @Override
    public Result getSummay(String object) {
        if (object.equals("riculture")){
            object="省农业农村厅";
        }
        if (object.equals("healthgh")){
            object="省卫生健康委";
        }
        if (object.equals("polinhfce")){
            object="省公安厅";
        }
        if(object.equals("hmr")){
            object="省人力资源社会保障厅";
        }
        if(object.equals("commerce")){
            object="省商务厅";
        }
        if(object.equals("drugControl")){
            object="省缉毒厅";
        }
        String getSummay =(String) redisUtils.get("getSummay");
        if (StrUtil.isNotBlank(getSummay)){
            return Result.ok(getSummay);
        }
        List<Bumentai> summay = managerMapper.getSummay(object);
        if (summay.size()>0){
            return Result.ok(summay);
        }else {
            return Result.error("查询失败");
        }

    }
}

